package com.fancy.learncenter.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.activity.FancyActivityDetailActivity;
import com.fancy.learncenter.activity.LifeVideoDetailActivity;
import com.fancy.learncenter.activity.TrainVideoDetailActivity;
import com.fancy.learncenter.activity.VideoDetailActivity;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.LifeVideoListDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

/**
 * Created by hyy on 2018/3/28.
 */

public class FancyVideoAdapter extends CommonRecycleViewAdapter<LifeVideoListDataBean> {
    public FancyVideoAdapter(Context mContext, ArrayList<LifeVideoListDataBean> itemDatas) {
        super(mContext, R.layout.activity_fancy_video_item, itemDatas);
    }


    @Override
    public void bindView(CustomViewHold customViewHold, final LifeVideoListDataBean item, final int position) {
        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());


        SimpleDraweeView person_ic = customViewHold.getView(R.id.person_ic);
        person_ic.setImageURI(item.getAvatar_img());


        TextView name = customViewHold.getView(R.id.name);
        name.setText(item.getNick_name());


        TextView play_num = customViewHold.getView(R.id.play_num);
        play_num.setText(item.getTop_num() + "");


        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(mContext, LifeVideoDetailActivity.class);

                intent.putExtra(VideoDetailActivity.VEDIO_KEY, item.getId());

                mContext.startActivity(intent);
            }
        });
        customViewHold.getRoorView().setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                if (deleteCallBack != null) {
                    deleteCallBack.deleteCallBack(position);
                }
                return true;
            }
        });


    }

    private DeleteCallBack deleteCallBack;

    public DeleteCallBack getDeleteCallBack() {
        return deleteCallBack;
    }

    public void setDeleteCallBack(DeleteCallBack deleteCallBack) {
        this.deleteCallBack = deleteCallBack;
    }

    public interface DeleteCallBack {
        abstract void deleteCallBack(int position);
    }
}
